//
//  CinemaTableViewCell.m
//  豆瓣
//
//  Created by Roach on 16/6/24.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "CinemaTableViewCell.h"
#import "CinemaModel.h"

#define kWidth self.contentView.frame.size.width
#define kHight self.contentView.frame.size.height
@interface CinemaTableViewCell ()

@property (nonatomic, retain) UILabel *cinemaNameLabel;
@property (nonatomic, retain) UILabel *addressLabel;
@property (nonatomic, retain) UILabel *phoneLabel;
@property (nonatomic, retain) UIImageView *backgroundImageView;

@end

@implementation CinemaTableViewCell

-(void)dealloc {
    
    [_cinemaNameLabel release];
    [_addressLabel release];
    [_phoneLabel release];
    [_backgroundImageView release];
    [super dealloc];
    
}

- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backgroundImageView = [[UIImageView alloc]init];
        [self.contentView addSubview:_backgroundImageView];
        [_backgroundImageView release];
        
        self.cinemaNameLabel = [[UILabel alloc]init];
        [self.contentView addSubview:_cinemaNameLabel];
        [_cinemaNameLabel release];
        
        self.addressLabel = [[UILabel alloc]init];
        [self.contentView addSubview:_addressLabel];
        [_addressLabel release];
        
        self.phoneLabel = [[UILabel alloc]init];
        [self.contentView addSubview:_phoneLabel];
        [_phoneLabel release];
    }
    
    return self;
    
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    self.backgroundImageView.frame = CGRectMake(10, 15, kWidth - 20, kHight - 20);
//    _backgroundImageView.backgroundColor = [UIColor whiteColor];
    
    self.cinemaNameLabel.frame = CGRectMake(20, 20, kWidth * 0.8, 23);
//    _cinemaNameLabel.backgroundColor = [UIColor redColor];
    
    self.addressLabel.frame = CGRectMake(20, 40, kWidth - 28, 50);
//    _addressLabel.backgroundColor = [UIColor yellowColor];
    _addressLabel.font = [UIFont systemFontOfSize:15];
    _addressLabel.numberOfLines = 2;
    
    self.phoneLabel.frame = CGRectMake(20, 90, kWidth * 0.8, 23);
    _phoneLabel.font = [UIFont systemFontOfSize:13];
//    _phoneLabel.backgroundColor = [UIColor greenColor];
    
    
}

- (void)setCellModel:(CinemaModel *)cellModel{
    if (_cellModel != cellModel) {
        
        [_cellModel release];
        
        _cellModel = [cellModel retain];
        
    }
    
    [_backgroundImageView setImage:[UIImage imageNamed:@"bg_eventlistcell@2x"]];
    _addressLabel.text = cellModel.address;
    _phoneLabel.text = cellModel.telephone;
    _cinemaNameLabel.text = cellModel.cinemaName;
    
}

@end
